import React from 'react';
import * as ReactDOM from 'react-dom/client';
import { Provider } from 'react-redux';
import { RouterProvider } from 'react-router-dom';
import { ConfigProvider } from 'antd';
import zhCN from 'antd/locale/zh_CN';
import enUS from 'antd/locale/en_US';
import { store } from './store';
import { router } from './router';
import './locales'; // 初始化i18n
import './App.scss';

// 根据当前语言设置Ant Design的语言包
const getAntdLocale = () => {
  const currentLang = localStorage.getItem('i18nextLng') || 'zh-CN';
  return currentLang === 'zh-CN' ? zhCN : enUS;
};

const rootElement = document.getElementById('root');
if (!rootElement) throw new Error('Failed to find the root element');

const root = ReactDOM.createRoot(rootElement);

root.render(
  // <React.StrictMode>
    <Provider store={store}>
      <ConfigProvider locale={getAntdLocale()}>
        <RouterProvider router={router} />
      </ConfigProvider>
    </Provider>
  // </React.StrictMode>
); 